<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="content">
            <h:form>
                <h:panelGroup id="packingAndShipping" >
                    <p:panel header="Packing Order Details" >
                        <h:panelGrid columns="3">
                            <h:outputText value="#{bundle.ViewPackingOrderEntityLabel_id}"/>
                            <h:outputText value="#{packingOrderEntityController.selected.id}" title="#{bundle.ViewPackingOrderEntityTitle_id}"/>
                            <h:outputText value=""/>

                            <h:outputText value="Packing Order Status: "/>
                            <h:outputText value="#{packingOrderEntityController.selected.status}" title="#{bundle.ViewPackingOrderEntityTitle_status}"/>
                            <h:outputText value=""/>

                            <h:outputText value="Sales Order: "/>
                            <h:commandLink value="#{packingOrderEntityController.selected.shippingOrder.salesOrder.id}" action="/entities/salesOrderEntity/View.xhtml">
                                <f:setPropertyActionListener target="#{salesOrderEntityController.current}" value="#{packingOrderEntityController.selected.shippingOrder.salesOrder}" />
                            </h:commandLink>
                            <h:outputText value="#{packingOrderEntityController.selected.shippingOrder.salesOrder.internalStatus}"/>

                            <h:outputText value="Shipping Order: "/>
                            <h:outputText value="#{packingOrderEntityController.selected.shippingOrder.id}">
                            </h:outputText>
                            <h:outputText value="#{packingOrderEntityController.selected.shippingOrder.status}"/>

                            <p:separator /> 
                            <h:outputText value=""/>
                            <h:outputText value=""/>

                            <h:outputText value="#{bundle.ViewPackingOrderEntityLabel_createdAt}"/>
                            <h:outputText value="#{packingOrderEntityController.selected.createdAt}" title="#{bundle.ViewPackingOrderEntityTitle_createdAt}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                            <h:outputText value=""/>

                            <h:outputText value="#{bundle.ViewPackingOrderEntityLabel_createdBy}"/>
                            <h:outputText value="#{packingOrderEntityController.selected.createdBy.fullname}" title="#{bundle.ViewPackingOrderEntityTitle_createdBy}"/>
                            <h:outputText value=""/>

                            <h:outputText value="#{bundle.ViewPackingOrderEntityLabel_lastModifiedAt}"/>
                            <h:outputText value="#{packingOrderEntityController.selected.lastModifiedAt}" title="#{bundle.ViewPackingOrderEntityTitle_lastModifiedAt}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                            <h:outputText value=""/>

                            <h:outputText value="#{bundle.ViewPackingOrderEntityLabel_lastModifiedBy}"/>
                            <h:outputText value="#{packingOrderEntityController.selected.lastModifiedBy.fullname}" title="#{bundle.ViewPackingOrderEntityTitle_lastModifiedBy}"/>
                            <h:outputText value=""/>
                        </h:panelGrid>
                    </p:panel>
                    <br />

                    <ui:include src="/entities/shippingRequestEntity/ListShippingRequestsForPackingOrder.xhtml" />

                    <br />
                    <h:panelGroup rendered="#{loginBacking.listShippingOrder}" >
                        <p:commandButton value="Mark Packed" action="#{packingOrderEntityController.markPacked()}" 
                                         update="@form:packingAndShipping" rendered="#{!packingOrderEntityController.packed}"/>
                        <p:commandButton value="Mark Pack Pending" action="#{packingOrderEntityController.markUnpacked()}" 
                                         update="@form:packingAndShipping" rendered="#{packingOrderEntityController.packed}"/>
                        &nbsp;
                        <p:commandButton value="Mark Shipped" action="#{shippingOrderEntityController.markFulfilled()}" 
                                         update="@form:packingAndShipping" rendered="#{(!shippingOrderEntityController.fulfilled) and packingOrderEntityController.packed}"/>
                        <p:commandButton value="Mark Shipment Pending" action="#{shippingOrderEntityController.markUnfulfilled()}" 
                                         update="@form:packingAndShipping" rendered="#{shippingOrderEntityController.fulfilled}"/>
                        <br />
                        <br />
                    </h:panelGroup>
                    
                    <h:panelGroup rendered="#{loginBacking.viewPackingOnly}" >
                        <p:commandButton ajax="false" action="/entities/salesOrderEntity/View.xhtml" 
                                         value="Back to Sales Order" immediate="true"/>
                        <br />
                    </h:panelGroup>
                </h:panelGroup>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
